package br.mikhas.lab;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class MikhasClassLoader extends ClassLoader {

	public MikhasClassLoader() {
		super(MikhasClassLoader.class.getClassLoader());
	}

	@Override
	public Class<?> loadClass(String name) throws ClassNotFoundException {
		System.out.println(name);
		return super.loadClass(name);
	}

	public static void main(String[] args) throws ClassNotFoundException,
			SecurityException, NoSuchMethodException, IllegalArgumentException,
			IllegalAccessException, InvocationTargetException {
		ClassLoader loader = new MikhasClassLoader();

		Class<?> cls = loader.loadClass("br.mikhas.lab.Tests");
		System.out.println(cls.getClassLoader());
		Method method = cls.getMethod("main", (new String[0]).getClass());

		method.invoke(null, new Object[] { new String[] { "teste" } });
	}

}
